<?php
session_start();
include '../tools/tools.php';
if($_SESSION['logged_in']){
$user = $_SESSION['username'];
$ques_No = $_SESSION['ques_No'];
$db = local_db();
$cmd = $_POST['cmd'];
if($cmd=='easy'){
    $sql = "INSERT INTO `questions` (`contribute_No`) VALUES ('$ques_No')";
    $db->query($sql);

    $sql = "UPDATE `questions_con` SET `status` = 1, `checked` = 1, `user` ='$user' WHERE `questions_con`.`No` = $ques_No";
    $db->query($sql);
}else if($cmd == 'hard'){
    $sql = "INSERT INTO `questions_hard` (`contribute_No`) VALUES ('$ques_No')";
    $db->query($sql);

    $sql = "UPDATE `questions_con` SET `status` = 2, `checked` = 1, `user` ='$user' WHERE `questions_con`.`No` = $ques_No";
    $db->query($sql);

}else if($cmd == 'both'){
    $sql = "INSERT INTO `questions` (`contribute_No`) VALUES ('$ques_No')";
    $db->query($sql);
    $sql = "INSERT INTO `questions_hard` (`contribute_No`) VALUES ('$ques_No')";
    $db->query($sql);

    $sql = "UPDATE `questions_con` SET `status` = 3, `checked` = 1, `user` ='$user' WHERE `questions_con`.`No` = $ques_No";
    $db->query($sql);

}else if($cmd == 'bad'){
    $sql = "UPDATE `questions_con` SET `status` = 0, `checked` = 1, `user` ='$user' WHERE `questions_con`.`No` = $ques_No";
    $db->query($sql);
}

}